home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / pdselect / blizkick / modules / newalert.asm < prev    next >
Assembly Source File  |  2000-02-16  |  7KB  |  238 lines

  1. ; FILE: Source:modules/NewAlert.ASM          REV: 2 --- Display more info on Alert
  2.  
  3. *
  4. * Modified by Harry Sintonen. Changes by me are marked with ;hs comment.
  5. *
  6.  
  7. ; NewAlert - Shows the Taskname within an Alert
  8. ; © Jens Lorenz 1997
  9. ;
  10. ; very strongly based upon:
  11.  
  12. ;
  13. ; Example BlizKick Module
  14. ; ~~~~~~~~~~~~~~~~~~~~~~~
  15. ; This code shows how to create replacing BlizKick "Module".
  16. ; Should be quite self-explonary... (?)
  17. ;
  18. ; !CODE MUST BE FULLY PC-RELATIVE!
  19. ;
  20. ; Written by Harry Sintonen.
  21. ; This source code is Public Domain.
  22.  
  23.         incdir  "include:"
  24.         include "exec/execbase.i"
  25.         include "blizkickmodule.i"              ; Some required...
  26.  
  27. _LVORawDoFmt            EQU   -$20A
  28. _LVOOpenLibraryTagged   EQU   -$32A
  29. _LVOTimedDisplayAlert   EQU   -$336
  30. _LVOCloseLibrary        EQU   -$19E
  31.  
  32.  
  33.         SECTION MODULE,CODE
  34.  
  35. _DUMMY_LABEL
  36.         BK_MOD BKMF_ReplaceMode!BKMF_ExtResBuf,_end,(RTF_COLDSTART)<<24+39<<16+NT_UNKNOWN<<8+$C9,_name,_name,_init
  37.  
  38. ; Replace mode on, requires EXTRESBUF buffer, COLDSTART module, requires KS V39.x or better,
  39. ; module type NT_UNKNOWN, priority -55.
  40.  
  41. STACKBUF        EQU   300                       ; +100 - just to be safe ...
  42.  
  43. _init   clr.l   (0).w
  44.         movem.l d2/d7/a2/a3/a6,-(sp)
  45.         move.l  LastAlert(a6),d2
  46.         moveq   #-1,d0                          ; Display no alert?
  47.         cmp.l   d0,d2
  48.         beq     .exit
  49.  
  50.         lea     -STACKBUF(sp),sp
  51.         move.l  sp,a3
  52.         lea     SoftFail(pc),a0
  53.         move.l  d2,d0
  54.         swap    d0
  55.         cmp.b   #1,d0
  56.         bne.b   .skip0
  57.         lea     NoMem(pc),a0
  58.         bra.b   .skip1
  59.  
  60. .skip0  btst    #$1F,d2
  61.         bne.b   .skip1
  62.         tst.w   d0
  63.         beq.b   .skip1
  64.         lea     Recoverable(pc),a0
  65. .skip1  bsr     .dostr
  66.         lea     PressLeftie(pc),a0
  67.         bsr     .dostr
  68.         lea     Copyright(pc),a0
  69.         bsr     .dostr
  70.         clr.b   (a3)+
  71.  
  72.         lea     ErrorFmt(pc),a0
  73.         lea     LastAlert(a6),a1
  74.         lea     .PutChar(pc),a2
  75.         jsr     _LVORawDoFmt(a6)
  76.  
  77.         lea     37(a3),a3                       ; Adjust a3  ;hs
  78.         st      (a3)+
  79.  
  80. * decode the TaskName / CLICommandName *
  81.         move.l  (LastAlert+4)(a6),d0            ; ^Task -> d0
  82.         beq     .notask                         ; if 0
  83.         move.l  d0,a0                           ; Task/Process
  84.         move.b  8(a0),d0                        ; LN_TYPE
  85.         cmp.b   #NT_TASK,d0                     ; NT_TASK ???
  86.         beq.b   .task                           ; no CLI-Checking needed
  87.         cmp.b   #NT_PROCESS,d0                  ; NT_PROCESS
  88.         bne.b   .error                          ; neither Task nor Process ?!?!
  89.  
  90.         move.l  172(a0),d0                      ; process.cli -> d0
  91.         beq.b   .task                           ; no cli-struct -> get the Taskname
  92.         subq.l  #8,sp                           ;hs
  93.         move.l  140(a0),d1                      ; process.tasknum -> d1
  94.         move.l  d1,(sp)                         ; store process.tasknum  ;hs
  95.  
  96.         lsl.l   #2,d0                           ; d0 was a BPTR !!!
  97.         move.l  d0,a0                           ; BADDR(process.cli) -> a0
  98.         move.l  16(a0),d0                       ; cli.commandname -> a0
  99.         lsl.l   #2,d0                           ; d0 was a BSTR
  100.         move.l  d0,a0                           ; d0 -> a0
  101.         tst.b   (a0)                            ; Length = 0 ?
  102.         beq.b   .nocliname                      ;  -> no CommandName there
  103.  
  104.         addq.l  #1,a0                           ; skip Length of BSTR
  105.         move.l  a0,4(sp)                        ; BADDR(cli.commandname) -> ArgArray  ;hs
  106.         bra.b   .fmtcliname
  107.  
  108. .nocliname
  109.         lea     NoCLIName(pc),a2
  110.         move.l  a2,4(sp)                        ;hs
  111. ;        bra.b   .fmtcliname
  112.  
  113. * Format the CLICommandName + CLI-Number *
  114. .fmtcliname
  115.         lea     CLINameFmt(pc),a0
  116.         move.l  sp,a1                           ;hs
  117.         lea     .PutChar(pc),a2
  118.         jsr     _LVORawDoFmt(a6)
  119.         addq.l  #8,sp                           ;hs
  120.         bra.b   .try                            ; display the alert
  121.  
  122. * It's a task *
  123. .task
  124.         movea.l 10(a0),a2                       ; tc.ln.name
  125.         tst.b   (a2)                            ; Len = 0 ?
  126.         beq.b   .notaskname                     ; -> No TaskName there
  127.         bra.b   .fmttaskname
  128. .error
  129.         lea     Error(pc),a2                    ; Fatal Error
  130.         bra.b   .fmttaskname
  131. .notaskname
  132.         lea     NoTaskName(pc),a2               ; No TaskName
  133.         bra.b   .fmttaskname
  134. .notask
  135.         lea     NoTask(pc),a2                   ; No Task
  136. ;       bra.b   .fmttaskname
  137. * Format the TaskName *
  138. .fmttaskname
  139.         lea     TaskNameFmt(pc),a0
  140.         move.l  a2,-(sp)                        ; a2 = ^TaskName ;hs
  141.         move.l  sp,a1                           ;hs
  142.         lea     .PutChar(pc),a2
  143.         jsr     _LVORawDoFmt(a6)
  144.         addq.l  #4,sp                           ;hs
  145.  
  146. .try    moveq   #3,d0                           ; 3=intuition.library
  147.         jsr     _LVOOpenLibraryTagged(a6)
  148.         tst.l   d0
  149.         beq.b   .try                            ; crash!
  150.         move.l  (LastAlert+3*4)(a6),a1
  151.         move.l  a6,a3
  152.         move.l  d0,a6
  153.         move.l  d2,d0
  154.         move.l  sp,a0
  155.         moveq   #50,d1                          ; we have 1 Line more to display
  156.         jsr     _LVOTimedDisplayAlert(a6)
  157.         move.l  d0,a2
  158.         move.l  a6,a1
  159.         move.l  a3,a6
  160.         jsr     _LVOCloseLibrary(a6)
  161.  
  162.         lea     STACKBUF(sp),sp
  163.         clr.l   (0).w
  164.         moveq   #-1,d0                          ; No alert on next round, please!
  165.         move.l  d0,LastAlert(a6)
  166. .exit   move.l  a2,d0
  167.         movem.l (sp)+,d2/d7/a2/a3/a6
  168.         rts
  169.  
  170. * Copy the whole String *
  171. .dostr  clr.b   (a3)+
  172. .copy   move.b  (a0)+,(a3)+
  173.         bne.b   .copy
  174.         st      (a3)+
  175.         rts
  176.  
  177. * Copy one Char *
  178. .PutChar
  179.         move.b  d0,(a3)+
  180.         clr.b   (a3)
  181.         rts
  182.  
  183. ************** Data **************
  184.  
  185. _name   dc.b    'alert.hook',13,10,0
  186.         CNOP    0,2
  187.  
  188. NoMem   dc.b    38,15
  189.         dc.b    'not enough memory. ',0
  190. SoftFail
  191.         dc.b    38,15
  192.         dc.b    'Software Failure. ',0
  193. Recoverable
  194.         dc.b    38,15
  195.         dc.b    'Recoverable Alert. ',0
  196. Copyright
  197.         dc.b    38,40
  198.         dc.b    '(© Jens Lorenz 1997)',0
  199. PressLeftie
  200.         dc.b    234,15
  201.         dc.b    'Press left mouse button to continue.',0
  202. ErrorFmt
  203.         dc.b    142,30
  204.         dc.b    'Error:  %04x %04x   Task: %08lx',0
  205. TaskNameFmt
  206.         dc.b    1,14                            ; dc.w 270 doesn't work !
  207.         dc.b    40
  208.         dc.b    'TaskName: %-30.30s',0          ;hs
  209. CLINameFmt
  210.         dc.b    1,14                            ; dc.w 270
  211.         dc.b    40
  212.         dc.b    'CLI #%-2.2ld : %-30.30s',0     ;hs
  213. NoTask
  214.         dc.b    '» No Task «',0
  215. NoTaskName
  216.         dc.b    '» No TaskName «',0
  217. NoCLIName
  218.         dc.b    '» No CommandName «',0
  219. Error
  220.         dc.b    '» FATAL ERROR «',0
  221.  
  222.         CNOP    0,2
  223.  
  224. ;hs ArgArray
  225. ;hs         dc.l    0                               ; Arg #1
  226. ;hs         dc.l    0                               ; Arg #2
  227. ;hs
  228. ;hs There *can* be self modifying code, but that doesn't mean I like it... ;)
  229.  
  230.         CNOP    0,2
  231. _end
  232.  
  233.  
  234.    SECTION  VERSION,DATA
  235.  
  236.         dc.b    '$VER: alert.hook_MODULE 2.0 (2.4.97)',0   ;hs
  237.  
  238.